package com.example.blogsystem.model.common;

import lombok.Data;

@Data
public class Result {
    private ResultStatus code; //业务状态码
    private String errorMessage; //错误信息
    private Object data; //数据

    public static Result success(Object data){
        Result result = new Result();
        result.code = ResultStatus.SUCCESS;
        result.errorMessage = "";
        result.data = data;
        return result;
    }

    public static Result fail(String errorMessage){
        Result result = new Result();
        result.code = ResultStatus.FAIL;
        result.errorMessage = errorMessage;
        result.data = "";
        return result;
    }

    public static Result unLogin(){
        Result result = new Result();
        result.code = ResultStatus.UNLOGIN;
        result.errorMessage = "用户未登录";
        result.data = "";
        return result;
    }
}